const express = require('express');
const router = express.Router()

const { submitUserInfoData, getUserInfoData, checkUserMoney, rechargeUserMoney } = require('../../controller/web/UserController')
const { createUploadMiddleware } = require('../../middleware/UploadImageMiddleware')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')

// 上传用户头像图片
const uploadAvatarImages = createUploadMiddleware('Avatar')
router.post('/user/avatar', checkTokenMiddleware, uploadAvatarImages)

// 提交用户个人信息
router.post('/user/info', checkTokenMiddleware, submitUserInfoData)

// 获取用户个人信息
router.get('/user/:id', checkTokenMiddleware, getUserInfoData)

// 查询当前用户的账户余额
router.get('/user/:id/money', checkTokenMiddleware, checkUserMoney)

// 用户账户余额充值
router.patch('/user/:id/money/recharge', checkTokenMiddleware, rechargeUserMoney)

module.exports = router